﻿@model CMS.BL.Entity.tbl_SiteMap

<div class="sectionHeader">@(!(bool)ViewBag.OnlyOneImage && Model != null ? "Upload Page Images For " + Model.SM_Name : "Add Image")</div>
<div class="sectionWindow">
    <div class="btnToggleSection">Upload Images +</div>
    <form id="ImagesUpload" class="sectionContent" action="@ViewBag.UploadAction" method="post" enctype="multipart/form-data" >
        <div>
            <label>Upload Images</label>
            <span class="info">
                @(!(bool)ViewBag.OnlyOneImage ? 
                    "You can upload up to 3 images at a time. More than 3 images can be associated with a page. 1 images wil be selected at random for display on site with each visit." :
                    "You can only upload 1 image for this page. The image will be displayed at the top of the page.")
            </span>
        </div>
        <div>
            <label></label>
            <input type="file" name="file1" />
            @Html.HiddenFor(m => m.SiteMapID)
            <span class="description">You can upload only images.</span>
        </div>
        @if (!(bool)ViewBag.OnlyOneImage)
        {
        <div>
            <label></label>
            <input type="file" name="file2" />
            <span class="description">You can upload only images.</span>
        </div>
        <div>
            <label></label>
            <input type="file" name="file3" />
            <span class="description">You can upload only images.</span>
        </div>
        }
        <div class="btnContainer">
            @if ((bool)this.ViewBag.CanUploadImages)
            {
            <button type="submit" class="btnGreen" >Upload Images</button>
            }
        </div>
    </form>
</div>
<div class="sectionWindow">
    <div class="btnToggleSection">Images Uploaded +</div>
    <div class="sectionContent">
        @if (Model != null)
        {
        <div class="imagesGallery">
        @if (Model.tbl_Image.Count > 0)
        {
            foreach (var image in Model.tbl_Image)
            {
            <span>
                <img src="@(image.I_Path + image.I_Thumb)" alt="@image.I_Thumb" />
                @if ((bool)this.ViewBag.CanDeleteImage)
                {
                <input type="button" value="Delete" class="btnRed" data-imageID="@image.ImageID" data-bind="click: onDeleteImage"/>
                }
            </span>
            }
        }
        else
        {
            <span>No images have been uploaded.</span>
        }
        </div>
        }
    </div>
</div>
<div id="UploadWindow">
    <div>@((bool)ViewBag.OnlyOneImage ? "Image is" : "Images are") being uploaded.</div>
    <div id="Progressbar"></div>
</div>